/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entidad;

import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.io.Serializable;
import java.util.Collection;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *@NamedQuery(name = "Ordenentrada.findBNombreProveedor", query = "select o from ordenentrada o " +
        "inner join proveedores p on p.idProveedores = o.Proveedor_idProveedor"
        + " WHERE p.nombre like :nombre"),
 * @author a
 */
@Entity
@Table(name = "ordenentrada")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Ordenentrada.findAll", query = "SELECT o FROM Ordenentrada o"),
    @NamedQuery(name = "Ordenentrada.findByIdOrdenEntrada", query = "SELECT o FROM Ordenentrada o WHERE o.idOrdenEntrada = :idOrdenEntrada"),
    @NamedQuery(name = "Ordenentrada.findByFecha", query = "SELECT o FROM Ordenentrada o WHERE o.fecha = :fecha"),
    @NamedQuery(name = "Ordenentrada.findByTotal", query = "SELECT o FROM Ordenentrada o WHERE o.total = :total"),
    @NamedQuery(name = "Ordenentrada.findByNoFactura", query = "SELECT o FROM Ordenentrada o WHERE o.noFactura LIKE :noFactura"),
    @NamedQuery(name = "Ordenentrada.findByActivo", query = "SELECT o FROM Ordenentrada o WHERE o.activo = :activo")})
public class Ordenentrada implements Serializable {
    @Transient
    private PropertyChangeSupport changeSupport = new PropertyChangeSupport(this);
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "idOrdenEntrada")
    private Integer idOrdenEntrada;
    @Basic(optional = false)
    @Column(name = "fecha")
    @Temporal(TemporalType.DATE)
    private Date fecha;
    @Basic(optional = false)
    @Column(name = "total")
    private float total;
    @Column(name = "noFactura")
    private String noFactura;
    @Basic(optional = false)
    @Column(name = "activo")
    private boolean activo;
    @JoinColumn(name = "Proveedor_idProveedor", referencedColumnName = "idProveedores")
    @ManyToOne
    private Proveedores proveedoridProveedor;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "ordenEntradaidOrdenEntrada")
    private Collection<Lotes> lotesCollection;

    public Ordenentrada() {
    }

    public Ordenentrada(Integer idOrdenEntrada) {
        this.idOrdenEntrada = idOrdenEntrada;
    }

    public Ordenentrada(Integer idOrdenEntrada, Date fecha, float total, boolean activo) {
        this.idOrdenEntrada = idOrdenEntrada;
        this.fecha = fecha;
        this.total = total;
        this.activo = activo;
    }

    public Integer getIdOrdenEntrada() {
        return idOrdenEntrada;
    }

    public void setIdOrdenEntrada(Integer idOrdenEntrada) {
        Integer oldId = this.idOrdenEntrada;
        this.idOrdenEntrada = idOrdenEntrada;
        changeSupport.firePropertyChange("idOrdenEntrada", oldId, idOrdenEntrada);
    }

    public Date getFecha() {
        return fecha;
    }

    public void setFecha(Date fecha) {
        Date oldId = this.fecha;
        this.fecha = fecha;
        changeSupport.firePropertyChange("fecha", oldId, fecha);
    }

    public float getTotal() {
        return total;
    }

    public void setTotal(float total) {
        float oldId = this.total;
        this.total = total;
        changeSupport.firePropertyChange("total", oldId, total);
    }

    public String getNoFactura() {
        return noFactura;
    }

    public void setNoFactura(String noFactura) {
        String oldId = this.noFactura;
        this.noFactura = noFactura;
        changeSupport.firePropertyChange("noFactura", oldId, noFactura);
    }

    public boolean getActivo() {
        return activo;
    }

    public void setActivo(boolean activo) {
        boolean oldId = this.activo;
        this.activo = activo;
        changeSupport.firePropertyChange("activo", oldId, activo);
    }

    public Proveedores getProveedoridProveedor() {
        return proveedoridProveedor;
    }

    public void setProveedoridProveedor(Proveedores proveedoridProveedor) {
        Proveedores oldId = this.proveedoridProveedor;
        this.proveedoridProveedor = proveedoridProveedor;
        changeSupport.firePropertyChange("proveedoridProveedor", oldId, proveedoridProveedor);
    }

    @XmlTransient
    public Collection<Lotes> getLotesCollection() {
        return lotesCollection;
    }

    public void setLotesCollection(Collection<Lotes> lotesCollection) {
        this.lotesCollection = lotesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idOrdenEntrada != null ? idOrdenEntrada.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Ordenentrada)) {
            return false;
        }
        Ordenentrada other = (Ordenentrada) object;
        if ((this.idOrdenEntrada == null && other.idOrdenEntrada != null) || (this.idOrdenEntrada != null && !this.idOrdenEntrada.equals(other.idOrdenEntrada))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entidad.Ordenentrada[ idOrdenEntrada=" + idOrdenEntrada + " ]";
    }
    
    public void addPropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.addPropertyChangeListener(listener);
    }

    public void removePropertyChangeListener(PropertyChangeListener listener) {
        changeSupport.removePropertyChangeListener(listener);
    }
    
}
